package com.zly.login.controller;

import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {
    @GetMapping("/test")
    public String test() {
        return "test";
    }

    @PreAuthorize("hasAnyAuthority('ROLE_admin')")
    @GetMapping("/admin")
    public String admin() {
        return "admin";
    }

    @PostAuthorize("hasAnyRole('system')")
    @GetMapping("/system")
    public String system() {
        return "system";
    }

    @PostAuthorize("returnObject == 'filter' || returnObject == '' || #name == '1' ")
    @GetMapping("/filter")
    public String filter(@RequestParam String name) {
        return name;
    }
}
